1 00:00:00,720 --> 00:00:09,030 Hello and welcome to this video on our of functions our functions sometimes called fat Harrow functions 2 00:00:09,660 --> 00:00:18,990 have an abbreviated syntax for working with the function they are represented by BE equal sign and big 3 00:00:19,130 --> 00:00:21,360 great symbol. 4 00:00:22,960 --> 00:00:30,760 Don't confuse this with comparison operators because it does something quite different. 5 00:00:31,120 --> 00:00:34,400 So I'm going to illustrate with an example. 6 00:00:34,510 --> 00:00:38,860 So you can see how our all functions work side by side. 7 00:00:38,860 --> 00:00:48,260 My text editor here I have created a variable here called student lists. 8 00:00:48,280 --> 00:00:52,020 We've said that two equals two functions. 9 00:00:52,170 --> 00:01:00,670 We pass in it's too dense as I remember and there were console logging in the students that were passed. 10 00:01:00,880 --> 00:01:10,500 Here again I'm calling the function an impasse in it an array here we two values John and Jane. 11 00:01:10,730 --> 00:01:15,120 So this is a typical function expression. 12 00:01:15,190 --> 00:01:24,880 I'm going to re model this or refactor this code using an arrow function so you can see how the arrow 13 00:01:24,880 --> 00:01:27,150 function actually works. 14 00:01:27,580 --> 00:01:34,330 So that piece of code here if you run it inside the console of your web browser it will display something 15 00:01:34,330 --> 00:01:35,180 like this. 16 00:01:35,200 --> 00:01:43,760 So make sure you have the console selected and click on that to see the two values of the harrie's here 17 00:01:43,800 --> 00:01:48,210 which is this to here John and Jane. 18 00:01:48,610 --> 00:01:54,440 So now let's refactored this court with an hour of fanshen. 19 00:01:54,940 --> 00:01:55,470 Right let's. 20 00:01:55,480 --> 00:01:57,150 We -- up this course. 21 00:01:57,160 --> 00:02:04,490 First thing I want to do is remove this function key word and unleash that again let's remove that to 22 00:02:04,510 --> 00:02:09,730 trying to shorten because I remove this curly braces. 23 00:02:10,300 --> 00:02:13,570 That's the only one I get rid of that as well. 24 00:02:14,010 --> 00:02:17,530 I just bring that could be nearer. 25 00:02:17,580 --> 00:02:21,100 I'm also going to bring this console log here. 26 00:02:21,100 --> 00:02:30,250 I'm going to make print it on the same lie just to shorten the code and we need to add our function 27 00:02:30,280 --> 00:02:40,870 here so and do that and then the greater than sign so that our function in there so you can see just 28 00:02:40,870 --> 00:02:50,300 by using a function we have reduced the amount of code to be written we've actually shortened the code. 29 00:02:50,470 --> 00:02:52,900 So I expect to get the same output. 30 00:02:52,900 --> 00:03:00,580 I'm just going to see my code and our lunch my browser again and to see if I get the same I should get 31 00:03:00,580 --> 00:03:02,240 the same output. 32 00:03:02,320 --> 00:03:08,290 You can see here I'm getting the same outputs as you are using in browser Babbo transformer. 33 00:03:08,300 --> 00:03:10,610 Some got John and J. 34 00:03:10,780 --> 00:03:13,990 So that's basically how you use our function. 35 00:03:13,990 --> 00:03:21,260 The main purpose of an IRA function is to shorten the expression use. 36 00:03:21,460 --> 00:03:28,300 Okay so by using that got real optical embraces and should tint my code. 37 00:03:28,620 --> 00:03:37,210 I can solve for shorting this code because I'm only passing one argument which is the students I can 38 00:03:37,210 --> 00:03:41,940 remove the parenthesised that shoots to work. 39 00:03:42,160 --> 00:03:49,590 However if you are passing in more than one argument you do need to include them in parenthesis. 40 00:03:49,650 --> 00:03:52,810 So I'm going to say that wrong the code again. 41 00:03:53,070 --> 00:03:56,540 He should I should get the same output. 42 00:03:56,710 --> 00:03:58,370 I do a refresh. 43 00:03:58,510 --> 00:04:02,080 It can see the output is to the same. 44 00:04:02,140 --> 00:04:06,090 Alright so that's basically how our functions work. 45 00:04:06,580 --> 00:04:14,530 Functions are a great way to make your javascript code more readable and more compact.